package models

import (
	"github.com/astaxie/beego/orm"
	"time"
)

type LoginLogs struct {
	Id        int       `orm:"column(id);auto" description:"pk_id"`
	InfoId    uint      `orm:"column(info_id)" description:"登录用户的ID"`
	Username  string    `orm:"column(username);size(50)" description:"登录用户名"`
	Type      int8      `orm:"column(type)" description:"登录类型 1后台登录,2APP登录"`
	Password  string    `orm:"column(password);size(50)" description:"登录密码"`
	Ip        string    `orm:"column(ip);size(32);null" description:"登录IP"`
	Status    int8      `orm:"column(status)" description:"登录状态 1成功,2失败"`
	CreatedAt time.Time `orm:"column(created_at);type(datetime);null"`
	UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"`
}

func (m *LoginLogs) TableName() string {
	return "login_logs"
}

func init() {
	orm.RegisterModel(new(LoginLogs))
}

// 添加LoginLogs
func (m *LoginLogs) AddLoginLogs() (id int64, err error) {
	o := orm.NewOrm()
	id, err = o.Insert(m)
	return
}
